package com.tjdx.projectsubmission.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateUtil {
    public static int getWeek(Date date) {
        GregorianCalendar g = new GregorianCalendar();
        g.setTime(date);
        return g.get(Calendar.WEEK_OF_YEAR); //获得周数
    }

    /**
     * 获取日期的月份
     *
     * @param date 日期
     * @return 月份
     */
    public static int getMM(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.MONTH) + 1;
    }

    public static String quarter(Integer month) {
        String quarter = null;
        if (month >= 1 && month <= 3) {
            quarter = "1";
        } else if (month >= 4 && month <= 6) {
            quarter = "2";
        } else if (month >= 7 && month <= 9) {
            quarter = "3";
        } else if (month >= 10 && month <= 12) {
            quarter = "4";
        }
        return quarter;
    }


    public static String getSysYear(Date date) {
//        String year = String.valueOf(date.getYear());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        return sdf.format(date);
    }

    public static String getSysYear() {

        Calendar date = Calendar.getInstance();

        String year = String.valueOf(date.get(Calendar.YEAR));

        return year;

    }
}
